﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FrogEngine
{
	public static class PrecisionHelper
	{
		public static double D_RELATIVE_TOLERANCE = 0.000001;
		public static double D_ABSOLUTE_TOLERANCE = 0.000001;

		public static float EPSILON = 0.0000001f;
		public static float F_RELATIVE_TOLERANCE = 0.000001f;
		public static float F_ABSOLUTE_TOLERANCE = 0.000001f;

		public static bool Equal(float f1, float f2)
		{
			return Math.Abs(f1 - f2) <= F_ABSOLUTE_TOLERANCE || Math.Abs(f1 - f2) <= F_RELATIVE_TOLERANCE * Math.Max(Math.Abs(f1), Math.Abs(f2));
		}

		public static bool Equal(double d1, double d2)
		{
			return Math.Abs(d1 - d2) <= D_ABSOLUTE_TOLERANCE || Math.Abs(d1 - d2) <= D_RELATIVE_TOLERANCE * Math.Max(Math.Abs(d1), Math.Abs(d2));
		}
	}
}
